package cbfg.popup.demo

import android.os.Bundle
import android.view.View
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import cbfg.popup.BDialogFragment
import kotlinx.android.synthetic.main.fragment_df_demo.*

/**
 * @author:  Tom Hawk
 * 添加时间: 2020/9/7 15:40
 * 功能描述:
 */
class DFDemoFragment : Fragment(R.layout.fragment_df_demo), View.OnClickListener {
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        btnTopStart.setOnClickListener(this)
        btnTopEnd.setOnClickListener(this)
        btnBottomStart.setOnClickListener(this)
        btnBottomEnd.setOnClickListener(this)
        btnCenter.setOnClickListener(this)
        btnSlideInBottom.setOnClickListener(this)
        btnInput.setOnClickListener(this)
        btnInputDialog.setOnClickListener(this)
        btnSelection.setOnClickListener(this)
    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.btnTopStart -> {
                val dialog = BDialogFragment()
                dialog.setLayoutRes(R.layout.fragment_df_top_start)
                dialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.DimTheme)
                dialog.show(childFragmentManager, "TopStart")
            }

            R.id.btnTopEnd -> {
                val dialog = BDialogFragment()
                dialog.setLayoutRes(R.layout.fragment_df_top_end)
                dialog.show(childFragmentManager, "TopEnd")
            }

            R.id.btnBottomStart -> {
                val dialog = BDialogFragment()
                dialog.setLayoutRes(R.layout.fragment_df_bottom_start)
                dialog.show(childFragmentManager, "BottomStart")
            }

            R.id.btnBottomEnd -> {
                val dialog = BDialogFragment()
                dialog.setLayoutRes(R.layout.fragment_df_bottom_end)
                dialog.show(childFragmentManager, "BottomEnd")
            }

            R.id.btnCenter -> {
                val dialog = BDialogFragment()
                dialog.setLayoutRes(R.layout.fragment_df_center)
                dialog.show(childFragmentManager, "Center")
            }

            R.id.btnSlideInBottom -> SlideInBottomDF().show(childFragmentManager, "SlideInBottom")

            R.id.btnInput -> {
                val dialog = BDialogFragment()
                dialog.setLayoutRes(R.layout.fragment_df_input)
                dialog.show(childFragmentManager, "Input")
            }

            R.id.btnInputDialog -> InputDF().show(childFragmentManager, "InputDialog")
            R.id.btnSelection -> OptionsDF().show(childFragmentManager, "Options")
        }
    }
}